﻿import rospy
import serial
import serial.tools.list_ports
import threading
import json
from std_msgs.msg import String


def rcv_data():
    global client
    global control_info_pub
    while True:
        rcv=client.readline()
        if (rcv):
            rcv = "start"
            control_info_pub.publish(rcv)
            rospy.loginfo("Publish cloud_control message %s",
                            rcv)

if __name__ == '__main__':

    global client
    client = serial.Serial("/dev/ttyTHS1",115200,timeout=0)

    rospy.init_node('pos_subscriber',anonymous=True)
    global control_info_pub
    control_info_pub = rospy.Publisher(
        '/control_info', String, queue_size=10)
        
    th=threading.Thread(target=rcv_data)
    th.start()

    
    